﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DIProject
{
    public partial class Login : System.Windows.Forms.Form// Form
    {
        private Form _parent;
        public Login(Form parent)
        {
            InitializeComponent();
            _parent = parent;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            
            if (_parent != null)
            {
                Application.Exit();
               // this.Close();
               // _parent.Close();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            FirstForm ff = this._parent as FirstForm;
            if (ff != null)
            {
                if (ff.CheckLogin(txbLogin.Text, txbPassword.Text))
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Неверное сочетание логина/пароля. Вход невозможен! Повторите попытку.", "Повторите попытку", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void Login_Shown(object sender, EventArgs e)
        {
            this.Location = new Point(100, 100);
        }
    }
}